
#ifndef __GAME_H__
#define __GAME_H__

#include "Globals.h"

// define the global constants
#define SPRITE_HEIGHT	9
#define CURSOR_HEIGHT	11

typedef struct
{
	// defines the current quatrant for the map
	int qX, qY;
	int qXMax, qYMax;

	// array for the cursor coordinates
	int cursor[2];

	// map size variables
	int mapWidth;
	int mapHeight;

	// pointer to world map array
	char *worldmap;
	char mapSaveNum;

	// Creates the array for the improvements - [MAP_HEIGHT][MAP_WIDTH][4]
	// 0 - road, 1 - irrigation, 2 - mine, 3 - railroad
	bool *improv;

	// array for bonus terrain array
	char *bonusTerrain;

	// Random seed for creating terrain bonuses
	long randomSeed;

	// Variables for turns
	int turn;
	int maxTurns;
	bool cont;

	// Data
	char *civ_names;
	char *city_names;
	unsigned short int *unitpic;
	unsigned short int *backpic;

} Game;

// Global variables held in game
extern Game game;

//
// Public Functions
//

// Initialize a game
void InitializeGame();
// Create a game, either makes a new one or loads
void CreateGame();
// Does one turn for the player then AI
void ProcessTurn();

// Gets the global cursor position
int GetCursorX();
int GetCursorY();

// macro for accessing world map array
#define Worldmap(X,Y) game.worldmap[(X)*game.mapWidth+(Y)]	
// macro for accessing improv array
#define Improv(X,Y,Z) game.improv[(X)*game.mapWidth*4+(Y)*4+(Z)]
// macro for accessing bonusTerrain array
#define Bonus(X,Y) game.bonusTerrain[(X)*game.mapWidth+(Y)]

//
// Private Functions
//

// Loads the data from the files
void LoadGameData();
// Frees all the game data
void FreeGameData();
// Starts a new game
void NewGame();
// Initializes the positions of the civs
void SetupCivs();
// Create bonus terrain
void GenerateBonusTerrain(long seed);
// Process AI turns
void ProcessAI();

#endif